/**
 *Copyright(c) HNA SYSTEMS Co., LTD
 *
 *@date 2013-7-23
 * 	
 *Original Author: 郑兴(zhengxing)
 *
 *ChangeLog
 *
 */
package com.hnas.sys.domain;

import java.util.HashMap;

/**
 * @author 郑兴(zhengxing)
 *
 */
public enum PackageStatus {
	HIDDEN("HIDE"),	// 不显示
	SHOW("SHOW");	// 显示
	
	/**
	 * Alias name. This is the name which will be stored in database.
	 */
	private final String alias;

	/**
	 * A hash map which keep all the action enum with alias name as key.
	 */
	private static HashMap<String, PackageStatus> map;

	/**
	 * Construct the hash map at load time
	 */
	static 
	{
		map = new HashMap<String, PackageStatus>();
		for (PackageStatus type : PackageStatus.values()) {
			map.put(type.alias, type);
		}
	}

	/**
	 * 构造函数
	 * @param alias
	 */
	PackageStatus(String alias) 
	{
		this.alias = alias;
	}

	/*
	 * (non-Javadoc)
	 * @see java.lang.Enum#toString()
	 */
	public String toString()
	{
		return this.alias;

	}

	/**
	 * Return a <code>PackageStatus</code> object holding the value of specified alias name
	 *
	 * @param alias
	 *            the alias name of the type
	 *
	 * @return a <code>PackageStatus</code> object holding the value represented by the alias name
	 *         argument
	 */
	public static PackageStatus valueOfAlias(String alias) 
	{
		PackageStatus type = map.get(alias);
		if (type == null) {
			throw new IllegalArgumentException("Unknown action alias [" + alias + "]");
		}

		return type;
	}

	/**
	 * @return the alias
	 */
	public String getAlias() {
		return this.alias;
	}
}
